<template>
    <el-dialog custom-class="add-dialog"
               :visible.sync="dialogFormVisible"
               title="反馈添加"
               :close-on-click-modal="false">
        <el-form ref="form"
                 :model="form"
                 label-width="80px"
                 class="box_acct_form">
            <el-row :gutter="24">
                <el-col :span="24">
                    <el-form-item label="反馈人:">
                        <el-input size="medium"
                                  v-model="form.username"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row :gutter="24">
                <el-col :span="24">
                    <el-form-item label="反馈内容:">
                        <el-input type="textarea"
                                  :rows="8"
                                  v-model="form.feedtext"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <span slot="footer"
              class="dialog-footer">
            <el-button type="primary"
                       class="full-width"
                       @click="close">取消</el-button>
            <el-button type="primary"
                       class="full-width"
                       @click="submit">反馈提交</el-button>
        </span>
    </el-dialog>
</template>

<script>
    export default {
        name: "userDialog",
        data(){
            return{
                dialogFormVisible: false,
                form:{
                    username: '',
                    feedtext: ''
                },

            }
        },
        created(){
            this.$axiosToken({
                url: '/users/getUserByToken',
                method: 'get',
                data: {},
                success:(result=>{
                    this.form.username = result.username
                })
            });
        },
        mounted(){

        },
        methods:{
            init(row){
              this.form = row
            },
            // 取消
            close(){
                this.dialogFormVisible = false
            },
            // 提交反馈
            submit(){
                this.$axiosToken({
                    url: '/poster/addFeedBack',
                    method: 'post',
                    data:{
                        username: this.form.username,
                        feedtext: this.form.feedtext
                    },
                    success: (result)=>{
                        this.$message({
                            message: '反馈成功',
                            type: 'success',
                            duration: 2000
                        });
                        this.dialogFormVisible = false;
                        this.$parent.getFeedbackData();
                    }
                });
            }


        }
    }
</script>

<style scoped>
    /deep/.el-dialog__title{
        line-height: 24px;
        font-size: 20px;
        color: #303133;
        font-weight: bolder
    }
    .el-button{
        font-size: 14px;
    }
    /deep/.el-textarea__inner{
        /*font-family: 微软雅黑;*/
        font-family: 楷体;
        font-size: 15px;
    }
</style>